--[[ Lambda CastingFrames
     Part of LambdaUI made by Gaius
	 Graphics are made by Gaius
	 ------------------------------
	 Contact me in irc://phcnet.de/#wow-interface
--]]

local filePath = "Interface\\AddOns\\LambdaUI\\"
local genericFilePath = "Interface\\AddOns\\LambdaUI\\Generic\\"

local Lambda = {}

function Lambda:new(colorR, colorG, colorB, colorA, flag)
	local Lambda = {}
	local filePath = filePath.."CastBar\\"
	
	if not flag then
		Lambda = CastingBarFrame
		else
		Lambda = flag
	end
	Lambda:SetWidth(480)
	Lambda:SetHeight(10)
	
	Lambda:SetStatusBarTexture("Interface\\Buttons\\WHITE8x8")
	Lambda:SetStatusBarColor(colorR, colorG, colorB, colorA)
	Lambda.SetStatusBarColor = function() end
	
	for i,v in pairs({Lambda:GetRegions()}) do
		if v:GetObjectType() == "FontString" then
			v:ClearAllPoints()
			v:SetAllPoints(Lambda)
			v:SetJustifyH("LEFT")
			v:SetFont(genericFilePath.."bold.ttf", 7, nil)
			v:SetShadowColor(0,0,0,0)
		end
		if v:GetObjectType() == "Texture" then
			if v:GetTexture() ~= "Interface\\Buttons\\WHITE8x8" then -- do not hide the statusbar!
				v:Hide()
				v.Show = function() end
				v = nil
			else
				v:ClearAllPoints()
				v:SetPoint("TOPLEFT",Lambda,"TOPLEFT",2,-2)
				v:SetPoint("BOTTOMRIGHT",Lambda,"BOTTOMRIGHT",-2,2)
				v.SetPoint = function() end
			end
	    end
	end
	
	Lambda:SetBackdrop( { bgFile = nil, edgeFile = filePath.."Border.tga", tile = false, tileSize = 0, edgeSize = 1, insets = nil })
	Lambda:SetBackdropBorderColor(colorR, colorG, colorB, colorA)
	
	Lambda.Resize = function(newScale)
		Lambda:SetScale(newScale)
		LambdaUI.Scalings[Lambda:GetName()] = Lambda:GetScale() -- save scalefactor
	end
	
	Lambda.Lock = function()
		Lambda.Show = Lambda:Show() -- restore
		Lambda:SetUserPlaced(false)
		Lambda:RegisterForDrag(nil)
		LambdaUI.Positions[Lambda:GetName()] = Lambda:GetPoint(1) -- save position
	end
	
	Lambda.Unlock = function()
		Lambda:SetUserPlaced(true)
		Lambda:Show()
		Lambda.Show = function() end -- disable hidding
		
		Lambda:RegisterForDrag("RightButton")
	end
	
	Lambda:SetScript("OnDragStart", function()
		Lambda:StartMoving()
	end)
	
	Lambda:SetScript("OnDragStop", function()
		Lambda:StopMovingOrSizing()
	end)
	
	table.insert(LambdaObjectTable,Lambda:GetName())
	
	return Lambda
end 

local LambdaCastBar = Lambda:new(0.964, 0.631, 0.102, 0.6)
LambdaCastBar:ClearAllPoints()
LambdaCastBar:SetPoint("CENTER", UIParent,"CENTER", 0, -100)
LambdaCastBar.SetPoint = function() end

TargetFrameSpellBar:SetParent(UIParent)
TargetFrameSpellBar.showCastbar = true

local LambdaEnemyCastBar = Lambda:new(0.592, 0.094, 0.094, 0.6, TargetFrameSpellBar)	
LambdaEnemyCastBar:ClearAllPoints()
LambdaEnemyCastBar:SetPoint("CENTER",UIParent,"CENTER", 0,-112)
LambdaEnemyCastBar.SetPoint = function() end 